package cn.glutnn.auth.domain.service.impl;

import cn.glutnn.auth.common.enums.IsDeletedFlagEnum;
import cn.glutnn.auth.domain.convert.AuthRoleConverter;
import cn.glutnn.auth.domain.entity.AuthRoleBO;
import cn.glutnn.auth.domain.service.AuthRoleDomainService;
import cn.glutnn.auth.infra.basic.entity.AuthRole;
import cn.glutnn.auth.infra.basic.service.AuthRoleService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * Author:   msh
 * Date:     2025/1/13 下午10:54
 * Description:
 */
@Service
@Slf4j
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {
    @Resource
    private AuthRoleService authRoleService;

    @Override
    public Boolean add(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleConverter.INSTANCE.convertBoToEntity(authRoleBO);
        authRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return authRoleService.save(authRole);
    }

    @Override
    public Boolean update(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleConverter.INSTANCE.convertBoToEntity(authRoleBO);
        return authRoleService.updateById(authRole);
    }

    @Override
    public Boolean delete(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleConverter.INSTANCE.convertBoToEntity(authRoleBO);
        authRole.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return authRoleService.updateById(authRole);
    }
}
